//
//				WidgetStyle.h
//

#ifndef __NEWA_WIDGETSTYLE_H
#define __NEWA_WIDGETSTYLE_H

#pragma message( "INCLUDING FILE: " __FILE__ )

#include "GraphicsBase.h"
#include <loki/SmartPtr.h>

namespace newa
{
	class Button;
	class ToggleButton;
	class CheckBox;
	class Label;
	class Frame;
	class FrameWithHeader;

	class WidgetStyle
	{
	public:
		virtual void paintButton( const Button&, PixBuf& )
		{}

		virtual void paintToggleButton( const ToggleButton&, PixBuf& )
		{}

		virtual void paintCheckBox( const CheckBox&, PixBuf& )
		{}

		virtual void paintLabel( const Label&, PixBuf& )
		{}

		virtual void paintFrame( const Frame&, PixBuf& )
		{}

		virtual void paintFrameHeader( const FrameWithHeader&, PixBuf& )
		{}
		
		virtual void paintFrameClientArea( const FrameWithHeader&, PixBuf& )
		{}

		virtual ~WidgetStyle()
		{}
	};

	namespace WidgetStyles
	{
		class Void : public WidgetStyle
		{
		public:
			void paintButton( const Button&, PixBuf& pb )
			{
 				void * buf = pb.buf();
 				::memset( buf, 0x00, pb.bufSize() / 2);
 				::memset( reinterpret_cast<char*> (buf) + pb.bufSize() / 2, 0xFF, pb.bufSize() / 2);
			}
			void paintToggleButton( const ToggleButton&, PixBuf& )
			{}
			void paintCheckBox( const CheckBox&, PixBuf& )
			{}
			void paintLabel( const Label&, PixBuf& pb )
			{
				void * buf = pb.buf();
				::memset( buf, 0x88, pb.bufSize() );
			}
		};
	}

	inline WidgetStyle& VoidStyle()
	{
		return Loki::SingletonHolder< WidgetStyle >::Instance();
	}

	class StyleManager
	{
	public:
		StyleManager()
		{
			applyStyle( &VoidStyle() );
		}

		void applyStyle( WidgetStyle * ws )
		{
			m_style = ws;
		}

		WidgetStyle& style()
		{
			return *m_style;
		}

	private:
		Loki::SmartPtr< WidgetStyle > m_style;
	};

	inline StyleManager& styleMan()
	{
		return Loki::SingletonHolder< StyleManager >::Instance();
	}

};

#endif
